<!-- 新建广告创意弹窗 -->
<div id="newCreatives" class="modal aside  top  fade" tabindex="-1" role="dialog" >

</div>

<div class="bg-white box-shadow pos-rlt"  >

  <div class="p-h-md p-v bg-white box-shadow pos-rlt">
    <h3 class="no-margin have-btn-title">广告管理</h3>
    <button id="newCreativesButton"  type="button" class="btn btn-sm btn-success ng-click-active pull-right pull-right"  data-placement="top" data-animation="am-slide-top aside-open-backdrop"  data-container="body"   bs-aside="aside"
    ><i class="glyphicon glyphicon-plus"></i>
    新建创意
    </button>
  </div>
</div>

<form id="creativesForm">
  <div class="p-md clear">
    <div class="panel-body advert-select" style="padding-top:0">
      <select name="crtSizeMediumMenuId"  id="crtSizeMediumMenuId" class="form-control w">
        <option value="0">全部尺寸</option>
        <% @crt_size_medium_menus&.each do |crt_size_medium_menu| %>
            <option value="<%= crt_size_medium_menu.crt_size %>"
            <% if @crtSizeMediumMenuId == crt_size_medium_menu.crt_size%>
              selected = 'selected'
            <%end %>
            ><%= crt_size_medium_menu.crt_size_detail%></option>
        <% end %>
      </select>
      <input id="crtSizeMediumMenuIdValue" type="hidden"  value="${form.crtSizeMediumMenuId }"/>
    </div>
    <% @ad_group_creatives&.each do |ad_group_creatives| %>

        <% if ad_group_creatives.crt_size_medium_menu_id == 1 %>
        <div class="cy-item col-sm-4">
          <div  class="panel b-a cy-materials-item">
            <div class="panel-heading bg text-lt"  >
              <span><%=  ad_group_creatives.creative_name%> </span>
                    <span class="pull-right del-icon-cy">
                      <%= link_to '', ad_group_creatives, method: :delete, data: {confirm: 'Are you sure?'} ,class: 'fa fa-trash-o m-l-sm materials-action-icon'%>
                    </span>
            </div>
            <div class="content">
              <div class="sb">
                <a href="<%=  ad_group_creatives.trademark_path%>"  target="_blank" >
                  <img src="<%=  ad_group_creatives.trademark_path%>" class="sb-icon">
                </a>
                <span class="sb-name"><%=  ad_group_creatives.trademark_name%></span>
              </div>
              <p class="cy-txt">
                <%=  ad_group_creatives.creative_copywriter%>
              </p>
            </div>
          </div>
        </div>

     <% end %>
        <% if ad_group_creatives.crt_size_medium_menu_id == 4 %>
        <div class="cy-item col-sm-4">
          <div  class="panel b-a cy-materials-item">
            <div class="panel-heading bg text-lt"  >
              <span><%=  ad_group_creatives.creative_name%></span>
                    <span class="pull-right del-icon-cy">
                        <%= link_to '', ad_group_creatives, method: :delete, data: {confirm: 'Are you sure?'} ,class: 'fa fa-trash-o m-l-sm materials-action-icon'%>
                    </span>
            </div>
            <div class="content">
              <div class="cy-img-list one mt">
                <a href="<%=  ad_group_creatives.banner_path1%>"  target="_blank" >
                  <img src="<%=  ad_group_creatives.banner_show_path1%>">
                </a>
              </div>
            </div>
          </div>
        </div>
        <% end %>
        <% if ad_group_creatives.crt_size_medium_menu_id == 5 %>

            <div class="cy-item col-sm-4">
              <div class="panel b-a cy-materials-item">
                <div class="panel-heading bg text-lt"  >
                  <span><%= ad_group_creatives.creative_name%></span>
                    <span class="pull-right del-icon-cy">
                       c
                    </span>
                </div>
                <div class="content">
                  <div class="sb">
                    <span class="sb-name"><%= ad_group_creatives.trademark_name%></span>
                  </div>
                  <p class="cy-txt">
                    <%= ad_group_creatives.creative_copywriter%>
                  </p>
                  <% if ad_group_creatives.banner_path2.nil? %>
                      <div class="cy-img-list one">
                        <a href="<%= ad_group_creatives.banner_show_path1%>"  target="_blank" >
                          <img src="<%= ad_group_creatives.banner_path1%>">
                        </a>
                      </div>
                  <% else %>
                      <div class="cy-img-list three">
                        <a href="<%= ad_group_creatives.banner_show_path1%>"  target="_blank" >
                          <img src="<%= ad_group_creatives.banner_path1%>">
                        </a>
                        <a href="<%= ad_group_creatives.banner_show_path2%>"  target="_blank" >
                          <img src="<%= ad_group_creatives.banner_path2%>">
                        </a>
                        <a href="<%= ad_group_creatives.banner_show_path3%>"  target="_blank" >
                          <img src="<%= ad_group_creatives.banner_path3%>">
                        </a>
                      </div>
                  <% end %>
                </div>
              </div>
            </div>
        <% end %>
        <% if ad_group_creatives.crt_size_medium_menu_id == 3 %>
            <div class="cy-item col-sm-4">
              <div class="panel b-a cy-materials-item">
                <div class="panel-heading bg text-lt"  >
                  <span>${frontSelfOperateCreative.creativeName}</span>
                    <span class="pull-right del-icon-cy">
                        <%= link_to '', ad_group_creatives, method: :delete, data: {confirm: 'Are you sure?'} ,class: 'fa fa-trash-o m-l-sm materials-action-icon'%>
                    </span>
                </div>
                <div class="content">
                  <div class="sb no-lineHeight">
                    <a href="<%= ad_group_creatives.share_path%> "  target="_blank" >
                      <img src="<%= ad_group_creatives.share_show_path%> " class="sb-icon">
                    </a>
                    <div class="sb-name-container have-desc-sbName">
                      <p class="sb-name"><%= ad_group_creatives.share_title%> </p>
                      <p class="sb-desc"><%= ad_group_creatives.share_describe%> </p>
                    </div>
                  </div>
                  <p class="cy-txt">
                    <%= ad_group_creatives.creative_copywriter%>
                  </p>
                  <div class="cy-img-list one">
                    <a href=" <%= ad_group_creatives.banner_path1%> "  target="_blank" >
                      <img src="<%= ad_group_creatives.banner_show_path1%> ">
                    </a>
                  </div>
                </div>
              </div>
            </div>
        <% end %>
        <% if ad_group_creatives.crt_size_medium_menu_id == 2 %>


                <div class="cy-item col-sm-4">
                  <div class="panel b-a cy-materials-item">
                    <div class="panel-heading bg text-lt"  >
                      <span> <%= ad_group_creatives.creative_name%></span>
                    <span class="pull-right del-icon-cy">
                    <%= link_to '', ad_group_creatives, method: :delete, data: {confirm: 'Are you sure?'} ,class: 'fa fa-trash-o m-l-sm materials-action-icon'%>
                </span>
                    </div>
                    <div class="content">
                      <p class="cy-txt mt">
                        <%= ad_group_creatives.creative_copywriter%>
                      </p>
                      <div class="cy-img-list one mt">
                        <a href="    <%= ad_group_creatives.banner_path1%> "  target="_blank" >
                          <img src=" <%= ad_group_creatives.banner_show_path1%> ">
                        </a>
                      </div>
                    </div>
                  </div>
                </div>
        <% end %>

    <% end %>
              </div>



              <div class="text-center">
<%= will_paginate  @ad_group_creatives%>
              </div>
              </form>


<script>

    function delectCreative(creativeId){
        $.ajax({
            url: "/ad_group_creative/delete",
            type: "POST",
            data:{id:creativeId},
            dataType: "json",
            cache: false,
            success: function(data) {
                if(data=="success"){
                    showMsg("success","创意删除成功！");
                    setTimeout("location.reload()", 1000);
                }else{
                    bootbox.dialog({
                        title:"删除创意提示",
                        message:"创意在使用中，无法删除。",
                        buttons:{
                            "success":{
                                "label" : "<i class='icon-ok'></i> 确定",
                                "className":"btn-sm btn-primary",
                                "callback" : function() {
                                }
                            }
                        }
                    });
                }
            }
        });
//        window.location.reload().delay(2000);
    }

    $().ready(function() {
        $("div[name=showOrhide]").hover(over, out)
        function over() {
            $(this).find("span").show()
        }

        function out() {
            $(this).find("span").hide();
        }
//根据尺寸查询
        $("#creativesForm").change(function(){
            $("#creativesForm").submit();
        })

//打开新建广告创意
        $("#newCreativesButton").click(function () {
//显示弹窗
            $.ajax({
                url: "<%= new_ad_group_creative_path %>",
                type: "GET",
                dataType: 'HTML',
                success: function (data) {
                    $("#newCreatives").html(data);
                    $("#newCreatives").modal("show");
                }
            });
        });
    })

</script>
<%= javascript_include_tag 'ad_group_creatives' ,'data-turbolinks-track': 'reload'%>
